package org.dromara.system.dict.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.system.dict.domain.IndicatorFactor;
import org.dromara.system.dict.domain.IndicatorType;
import org.dromara.system.dict.domain.UnitType;
import org.dromara.system.dict.mapper.IndicatorFactorMapper;
import org.dromara.system.dict.mapper.IndicatorTypeMapper;
import org.dromara.system.dict.mapper.UnitTypeMapper;
import org.dromara.system.dict.service.DictService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 字典表服务实现类
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class DictServiceImpl implements DictService {

    private final IndicatorFactorMapper indicatorFactorMapper;

    private final IndicatorTypeMapper indicatorTypeMapper;

    private final UnitTypeMapper unitTypeMapper;

    @Override
    public List<IndicatorFactor> queryIndicatorFactorByCode(String indicatorTypeCode) {
        LambdaQueryWrapper<IndicatorFactor> lqw = Wrappers.lambdaQuery();
        lqw.eq(IndicatorFactor::getIndicatorTypeCode, indicatorTypeCode);
        return indicatorFactorMapper.selectList(lqw);
    }

    @Override
    public List<IndicatorType> queryIndicatorTypeList() {
        return indicatorTypeMapper.selectList(null);
    }

    @Override
    public List<UnitType> queryUnitTypeList() {
        return unitTypeMapper.selectList(null);
    }
}
